package com.james.jni_base;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    // Used to load the 'native-lib' library on application startup.


    JavaTest javaTest;
    KotlinTest test;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // Example of a call to a native method
        javaTest = new JavaTest();
        TextView tv = findViewById(R.id.sample_text);
        tv.setText(javaTest.stringFromJNI());
        byte[] array = javaTest.returnByteArray();
        for (int i = 0; i < array.length; i++) {
            Log.i("array info:", array[i] + "");
        }
        String[] arrays = {"a", "b", "c"};
        Log.i("MainopteratString =", javaTest.MainopteratString("james", arrays));
        javaTest.CCallJavaStatic();
        javaTest.CDiaoJavaByOject();
        javaTest.changeValue();
        Log.i("java number= ", javaTest.number + "");
        Log.i("java content= ", javaTest.content);
        javaTest.dynamicJavaStringTest();
        javaTest.dynamicJavaTests("kevin");
        javaTest.setJNIEnv();
        test = new KotlinTest();
    }


    public void CatchException(View view) {
        javaTest.doit();
    }

    public void attach_pthread(View view) {
        javaTest.mainThread();
    }

    public void kotlinCall(View view) {
        Log.i("content = ", test.kotlinGetString());
    }
}
